/* Copyright (c) 2004-2024 peigen.info. All rights reserved. */

package info.peigen.hotpot.business.account.manage.convertor;

import cn.hutool.core.bean.BeanUtil;
import info.peigen.hotpot.business.account.core.repository.entity.BankEntity;
import info.peigen.hotpot.business.account.manage.form.BankManageCreateForm;
import info.peigen.hotpot.business.account.manage.form.BankManageEditForm;
import info.peigen.hotpot.business.account.manage.form.BankManageSearchForm;
import info.peigen.hotpot.business.account.manage.info.BankManageInfo;
import info.peigen.hotpot.common.core.domain.bank.Bank;
import info.peigen.hotpot.common.core.util.IdUtil;
import lombok.extern.slf4j.Slf4j;

/**
 * <b>(BankManageConvertor)</b>
 * 管理后台领域对象 "银行" 转换器
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2023-08-29
 */
@SuppressWarnings("unused")
@Slf4j
public class BankManageConvertor {
    // ConvertToEntity
    public static BankEntity convertToEntity(Bank domain) {
        return BeanUtil.copyProperties(domain, BankEntity.class);
    }

    public static BankEntity convertToEntity(BankManageInfo info) {
        return BeanUtil.copyProperties(info, BankEntity.class);
    }

    public static BankEntity convertToEntity(BankManageSearchForm form) {
        return BeanUtil.copyProperties(form, BankEntity.class);
    }

    public static BankEntity convertToEntity(BankManageCreateForm form) {
        if (form.getBankId() == null) {
            form.setBankId(IdUtil.id());
        }
        return BeanUtil.copyProperties(form, BankEntity.class);
    }

    public static BankEntity convertToEntity(BankManageEditForm form) {
        return BeanUtil.copyProperties(form, BankEntity.class);
    }

    // ConvertToDomain
    public static Bank convertToDomain(BankEntity entity) {
        return BeanUtil.copyProperties(entity, Bank.class);
    }

    public static Bank convertToDomain(BankManageInfo info) {
        return BeanUtil.copyProperties(info, Bank.class);
    }

    public static Bank convertToDomain(BankManageSearchForm form) {
        return BeanUtil.copyProperties(form, Bank.class);
    }

    public static Bank convertToDomain(BankManageCreateForm form) {
        if (form.getBankId() == null) {
            form.setBankId(IdUtil.id());
        }
        return BeanUtil.copyProperties(form, Bank.class);
    }

    public static Bank convertToDomain(BankManageEditForm form) {
        return BeanUtil.copyProperties(form, Bank.class);
    }

    // convertToInfo
    public static BankManageInfo convertToInfo(Bank domain) {
        return BeanUtil.copyProperties(domain, BankManageInfo.class);
    }

    public static BankManageInfo convertToInfo(BankEntity entity) {
        return BeanUtil.copyProperties(entity, BankManageInfo.class);
    }

    public static BankManageInfo convertToInfo(BankManageSearchForm form) {
        return BeanUtil.copyProperties(form, BankManageInfo.class);
    }

    public static BankManageInfo convertToInfo(BankManageCreateForm form) {
        if (form.getBankId() == null) {
            form.setBankId(IdUtil.id());
        }
        return BeanUtil.copyProperties(form, BankManageInfo.class);
    }

    public static BankManageInfo convertToInfo(BankManageEditForm form) {
        return BeanUtil.copyProperties(form, BankManageInfo.class);
    }
}